<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="container-div">
	<div class="tabs-container">
		<div class="wrapper wrapper-content animated fadeInRight ibox-content">
			<form class="form-horizontal m" id="form-integralConfig-add">
				<ul class="nav nav-tabs">
					<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 积分配置</a></li>
					<li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false"> 积分规则</a></li>
				</ul>
				<div class="tab-content">
					<div id="tab-1" class="tab-pane active">
						<div class="form-group"></div>
						<div class="form-group">
							<label class="col-sm-1 control-label"><span style="color: red">*</span>上报故障：</label>
							<div class="col-sm-3">
								<input id="reportFault" name="reportFault" class="form-control" type="text" required>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-1 control-label"><span style="color: red">*</span>上报困人：</label>
							<div class="col-sm-3">
								<input id="reportTiring" name="reportTiring" class="form-control" type="text" required>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-1 control-label"><span style="color: red">*</span>故障维修：</label>
							<div class="col-sm-3">
								<input id="faultRepair" name="faultRepair" class="form-control" type="text" required>
							</div>
						</div>
						<div class="form-group">
							<label class="col-sm-1 control-label"><span style="color: red">*</span>电梯保养：</label>
							<div class="col-sm-3">
								<input id="elevatorUpkeep" name="elevatorUpkeep" class="form-control" type="text" required>
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group" style="text-align: center">
							<div class="col-sm-5"></div>
							<div class="col-sm-1">
								<a class="btn btn-success" style="margin-left: 5px" href="javascript:void(0)" onclick="submitHandler1()">保存</a>
							</div>
							<div class="col-sm-1">
								<a class="btn btn-danger" style="margin-left: 5px" href="javascript:void(0)"  onclick="closeItem()">关闭</a>
							</div>
							<div class="col-sm-5"></div>
						</div>
					</div>
					<div id="tab-2" class="tab-pane">
						<div class="form-group"></div>
						<div class="form-group">
							<label class="col-sm-2 control-label"></label>
							<div class="col-sm-8">
								<input id="tinymceEditor" name="integralRules" class="form-control" type="text">
							</div>
						</div>
						<div class="hr-line-dashed"></div>
						<div class="form-group" style="text-align: center">
							<div class="col-sm-5"></div>
							<div class="col-sm-1">
								<a class="btn btn-success" style="margin-left: 5px" href="javascript:void(0)" onclick="submitHandler2()">保存</a>
							</div>
							<div class="col-sm-1">
								<a class="btn btn-danger" style="margin-left: 5px" href="javascript:void(0)"  onclick="closeItem()">关闭</a>
							</div>
							<div class="col-sm-5"></div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/tinymce/4.9.2/tinymce.min.js}"></script>
<script type="text/javascript">
	var prefix = ctx + "business/integralConfig";
	$("#form-integralConfig-add").validate({
		rules:{
			xxxx:{
				required:true,
			},
		}
	});
	//添加
	function submitHandler1() {
		$.ajax({
			url: prefix + "/add",
			type: "post",
			data: {
				"configId": [[${configId}]],
				"reportFault": $("#reportFault").val(),
				"reportTiring": $("#reportTiring").val(),
				"faultRepair" : $("#faultRepair").val(),
				"elevatorUpkeep": $("#elevatorUpkeep").val()
			},
			success: function(result) {
				$.modal.alertSuccess(result.msg)
			}
		})
	}
	//编辑
    function submitHandler2() {
		//动态为form增加对象
		var formIntegralConfigAdd=$('#form-integralConfig-add'); //得到form对象
		var tmpInput=$("<input type='text' type='hidden' name='configId'/>");
		tmpInput.attr("value", [[${configId}]]);
		formIntegralConfigAdd.append(tmpInput);
		if ($.validate.form()) {
			var html = tinymce.activeEditor.getContent();
			$("#tinymceEditor").val(html);
			$.ajax({
				url: prefix + "/edit",
				data: formIntegralConfigAdd.serialize(),
				type: "post",
				processData: false,
				contentType: false,
				success: function(result) {
					$.modal.alertSuccess(result.msg)
				}
			});
		}
    }
</script>
</body>
</html>
